﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Commons.IO
{
	public interface IDataSink<T> : IDisposable
	{
		void Close();

		Task FlushAsync();

		Task PushAsync(T[] data, CancellationToken token, IProgress<ProgressEventArgs> progress);
	}

	public static class DataSinks
	{
		public static Task PushAsync<T>(this IDataSink<T> sink, T data, CancellationToken token, IProgress<ProgressEventArgs> progress)
		{
			return sink.PushAsync(new[] { data }, token, progress);
		}
	}
}
